<!--
 @description 
 @fileName Item.vue
 @author zengqiongying
 @created 2023/04/15 14:18:29
-->
<template>
  <div class="customer-item" @click="onDetail">
    <div class="i-top">
      <span>{{ itemData.code }}</span>
      <span
        :class="{
          'color-normal': [1, '1'].includes(itemData.businessStatus), // 1 经营正常
          'color-grey': ![1, '1', 6, '6'].includes(itemData.businessStatus), // 4 预营业、2 预停业、3 已停业 ， 5 未开业停用
          'color-error': [6, '6'].includes(itemData.businessStatus) // 经营异常
        }"
      >
        {{ itemData.businessStatusName }}
      </span>
    </div>
    <div class="title color-black">{{ itemData.name }}</div>
    <div class="tags">
      <span v-if="itemData.marketLevelName" class="tag-line">{{ itemData.marketLevelName }}</span>
      <span class="tag-line">{{ itemData.twoCategoryName }}</span>
      <span class="tag-line">{{ itemData.agencyName }}</span>
    </div>
    <div v-if="businessTypeName.length > 0" class="tags">
      <span v-for="(name, i) in businessTypeName" :key="i" class="tag-rd">{{ name }}</span>
    </div>
    <div class="content">
      <div>
        经营总面积：<span class="black">{{ itemData.operateArea }}m<sup>2</sup></span>
      </div>
      <div>
        加盟时间：<span class="black">{{ parseTime(itemData.creationTime, '{y}年{m}月{d}日') }}</span>
      </div>
    </div>
  </div>
</template>

<script>
  import { defineComponent, computed } from 'vue'
  import { parseTime } from '@/utils'
  export default defineComponent({
    name: 'DealerCustomerItems',
    props: {
      itemData: {
        type: Object,
        default: () => {}
      }
    },
    setup(props, { emit }) {
      const onDetail = () => {
        emit('detail')
      }
      const businessTypeName = computed(() => {
        const { businessTypeName } = props.itemData
        if ([null, undefined, ''].includes(businessTypeName)) return []
        return businessTypeName.split(',')
      })
      return {
        onDetail,
        parseTime,
        businessTypeName
      }
    }
  })
</script>
<style lang="less" scoped>
  .customer-item {
    margin-bottom: 8px;
    padding: 16px;
    background: var(--bg-global-weaker);
    border-radius: 8px;
    font: var(--font-main-body);
    color: var(--texticon-default-stronger);
    .i-top {
      display: flex;
      justify-content: space-between;
      align-items: center;
      height: 20px;
      // font: var(--font-main-body);
      color: var(--texticon-color-brand-normal);
    }
    .title {
      padding: 2px 0;
      min-height: 22px;
      font: var(--font-main-title-strengthen);
    }
    .tags {
      display: flex;
      flex-wrap: wrap;
      align-items: center;
      .tag-line {
        position: relative;
        display: inline-flex;
        padding: 0 8px;
        height: 20px;
        margin-bottom: 2px;
        &::after {
          content: '';
          position: absolute;
          right: 0;
          top: 50%;
          width: 0;
          height: 14px;
          border: 1px solid var(--divisionline-normal);
          transform: translateY(-50%);
        }
        &:first-child {
          padding-left: 0;
        }
        &:last-child {
          padding-right: 0;
          &::after {
            display: none;
          }
        }
      }
      .tag-rd {
        display: inline-flex;
        padding: 2px 4px;
        margin-right: 2px;
        margin-bottom: 2px;
        border-radius: 2px;
        background: var(--bg-focusing-brand);
        font: var(--font-main-body);
        color: var(--texticon-color-brand-normal);
      }
    }
    .content {
      margin-top: 6px;
      div {
        padding: 2px 0;
      }
    }
  }
</style>
